How To Build Time Zone Database for ARM


Intro


In this How To we are going to build tzdata/zoneinfo 2013h with our GCC 4.8.2 cross-compiler.

This is how you populate /usr/share/zoneinfo. It was a little wonky because there was not a lot of documentation on how to do this, but is relatively easy. If you never heard of the forementioned website, you're not alone, I hadn't either. This came about when setting NTP up for the Pandaboard. The Pandaboard does not not have a RTC to keep track of system time, at least my version doesn't (PandaBoard ES Rev B2). A common workaround is to use NTP. Once I had that done I was not seeing the proper date for my geo location, note: I'm building my own Linux file system. Well, turns out this is why (tzdata). What's more frustrating is the lack of documentation on how to this. So, I hope this helps someone out there by saving them the time and agony I had to go through.

NOTE: This method only applies to individuals making a custom Linux file system and/or you don't have GNU Make! If you have Make installed you can use Make to compile the binaries and install: http://www.iana.org/time-zones/repository/tz-link.html

Tar Balls


Here is a list of source packages that we'll need for the build. You can either download them now or wait 'til later in the How To.
  • tzdata2013h.tar.gz

I recommend downloading the latest tzdataxxxxx.tar.gz from http://www.iana.org/time-zones.

Create a Workspace


I recommend creating a workspace under your /home/<your user>/ directory that is dedicated to this build. So let's fire up your terminal and run the following:
$ export TZDATA_SRC=~/workbench/tzdata/src
$ mkdir -pv ~/workbench/tzdata
$ mkdir $TZDATA_SRC
$ cd $TZDATA_SRC

Gather the Sources


Now that we have a workspace created and we are currently in the src directory we can begin bringing down the sources and extracting them.

tzdata

$ wget pkgs.fedoraproject.org/repo/pkgs/tzdata/tzdata2013h.tar.gz/d310abe42cbe87e76ceb69e2c7003c92/tzdata2013h.tar.gz
$ tar -pxzf tzdata2013h.tar.gz

Build Environment


Here is where things start to become a little janky. There is probably a better way to do this, but this is what worked for me:
$ cp -rp /home/<your user>/workbench/gcc-4.8.2/arm /<your custom Linux file system>
$ cp /home/<your user>/workbench/tzdata/src/* /<your custom Linux file system>
What we are doing above is moving a piece of the arm compiler to our custom Linux file system. Next, we move the extracted files, all of them, over to our custom Linux file system. If you have a /home directory already made then put them there. If you already have tar available on your custom Linux file system then just move tzdata2013h.tar.gz and untar it when you boot your system. Clear as mud 8-)

Build tzdata


Now that we have the binaries we need to build on our custom Linux file system, as well as tzdata itself. Note that we are doing this on our dev board. We are going to use zic to build tzdata. Go ahead and boot the board with your custom Linux file system and do the following:
$ cd /<where you moved tzdata files to in previous step>
$ <where you moved arm binaries to in previous step>/arm/sysroot/usr/sbin/zic <wherever you put them>/etcetera
$ <where you moved arm binaries to in previous step>/arm/sysroot/usr/sbin/zic <wherever you put them>/southamerica
$ <where you moved arm binaries to in previous step>/arm/sysroot/usr/sbin/zic <wherever you put them>/northamerica
$ <where you moved arm binaries to in previous step>/arm/sysroot/usr/sbin/zic <wherever you put them>/europe
$ <where you moved arm binaries to in previous step>/arm/sysroot/usr/sbin/zic <wherever you put them>/africa
$ <where you moved arm binaries to in previous step>/arm/sysroot/usr/sbin/zic <wherever you put them>/antarctica
$ <where you moved arm binaries to in previous step>/arm/sysroot/usr/sbin/zic <wherever you put them>/asia
$ <where you moved arm binaries to in previous step>/arm/sysroot/usr/sbin/zic <wherever you put them>/australasia
$ <where you moved arm binaries to in previous step>/arm/sysroot/usr/sbin/zic <wherever you put them>/backward
$ <where you moved arm binaries to in previous step>/arm/sysroot/usr/sbin/zic <wherever you put them>/pacificnew
$ <where you moved arm binaries to in previous step>/arm/sysroot/usr/sbin/zic <wherever you put them>/solar87
$ <where you moved arm binaries to in previous step>/arm/sysroot/usr/sbin/zic <wherever you put them>/solar88
$ <where you moved arm binaries to in previous step>/arm/sysroot/usr/sbin/zic <wherever you put them>/solar89
$ <where you moved arm binaries to in previous step>/arm/sysroot/usr/sbin/zic <wherever you put them>/systemv
 

Output


Check that you have a directory called zoneinfo:
$ ls /usr/share
Now we need to create a symlink to set our timezone:
$ ln -s /usr/share/zoneinfo/<country>/<city> /etc/localtime
Next, go delete the files you used to create zoneinfo in the step above, i.e. arm directory, etc. Like I said earlier there is probably a better way to do this. For more info take a look at the README and Makefile that comes with the tzdata package.
http://www.iana.org/time-zones/repository/tz-link.html